import gov.nih.mipav.model.structures.VOI;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.util.HashMap;

import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;

public class InitialPointsManager extends Module implements Drawable,
    MethodRelated {

  /** The factory */
  private InitialPointsFactory initialPointsFactory;

  public InitialPointsManager() {
    super();
    initialPointsFactory = new InitialPointsFactory();
  }

  /**
   * Draws the pane containing the initialPoint factory-
   */
  public Component drawContentPane() {
    JPanel initialPointsPane = new JPanel();
    initialPointsPane.setBorder(new TitledBorder("InitialPoints Selector"));
    initialPointsPane.setLayout(new BorderLayout(2, 2));
    JComboBox ipComboBox = initialPointsFactory.createComboBox();
    ipComboBox.setMinimumSize(new Dimension(100, 20));
    initialPointsPane.add(ipComboBox, BorderLayout.CENTER);
    initialPointsPane.add(RegionManager.getInstance().drawContentPane(),
        BorderLayout.EAST);
    initialPointsPane.add(VOIManager.getInstance().drawContentPane(), BorderLayout.SOUTH);
    return initialPointsPane;
  }

  public void setEnable(boolean enable) {
  }

  protected void updateMe() {
    initialPointsFactory.update();
  }

  public void updateProxy() {
    initialPointsFactory.updateProxy();
  }

  public String getInitialPointsName() {
    return (String) initialPointsFactory.getSelectedItem();
  }

  public HashMap<VOI, String> getRegisteredVOIs() {
    return initialPointsFactory.getRegisteredVOIs();
  }

  /**
   * JSInitialPointManager must always send an update since it only calls the update for its
   * inner components.
   */
  public boolean needsToBeUpdated() {
    return true;
  }

}
